n, b = map(int, input().split())


class Bu:
    def __init__(self, p, s):
        self.p = p
        self.s = s


items = [Bu(0, 0) for _ in range(n)]
for i in range(n):
    p, s = map(int, input().split())
    items[i] = Bu(p, s)
items.sort(key=lambda bu: bu.p + bu.s)
# 从前向后枚举 记录最大的货款 对那一次进行打折
max_val = 0
cost = 0
for i in range(n):
    cost += items[i].p + items[i].s
    if items[i].p > max_val:
        cost += max_val // 2
        max_val = items[i].p
        cost -= max_val // 2
    if cost > b:
        print(i)
        break
